<template>
  <div class="">
    <van-nav-bar left-text="修改密码" left-arrow @click-left="onClickLeft" />
    <div class="" style="margin: 24px 15px 0px;background: #FFFFFF;border-radius: 5px;padding-bottom: 20px;">
      <van-form @submit="onSubmit">
        <van-field disabled v-model="username" :name="user.name" label="用户名" :placeholder="user.name"
          style="font-size: 14px;font-weight: 500;color: #666666;font-family:auto"
          :rules="[{ required: true, message: '请填写用户名' }]" />
        <van-field v-model="password" type="password" name="原密码" label="原密码" placeholder="原密码"
          style="font-size: 14px;font-weight: 500;color: #666666;font-family:auto"
          :rules="[{ required: true, message: '请填写原密码' }]" />
        <van-field v-model="nowpassword" type="password" name="新密码" label="新密码" placeholder="新密码"
          style="font-size: 14px;font-weight: 500;color: #666666;font-family:auto"
          :rules="[{ required: true, message: '请填写新密码' }]" />
        <van-field v-model="nowpassword1" type="password" name="重复新密码" label="重复新密码" placeholder="重复新密码"
          style="font-size: 14px;font-weight: 500;color: #666666;font-family:auto"
          :rules="[{ required: true, message: '重复新密码' }]" />
        <div class="flex-c" @click="setpwd"
          style="margin: 20px;height: 33px; font-weight: bold;color: #FFFFFF;font-size: 15px;font-family:auto;background: #0580FF;border-radius: 5px;">
          提交
        </div>
      </van-form>
    </div>
  </div>
  <!-- 修改密码 -->

</template>

<script>
  import {
    SetPwd
  } from '@/api/my/SetPwd.js'
  import {
    Toast
  } from 'vant'
  export default {
    data() {
      return {
        username: '',
        password: '',
        nowpassword: '',
        nowpassword1: '',
        user: {}
      }
    },
    created() {

      this.user = JSON.parse(localStorage.getItem('user'));

    },
    methods: {
      onClickLeft() {
        this.$router.go(-1)
      },
      onSubmit() {

      },
      setpwd() {
        SetPwd({
          UserName: this.user.name,
          OldPwd: this.password,
          NewPwd1: this.nowpassword,
          NewPwd2: this.nowpassword1
        }).then(res => {
          Toast(res.message);
          this.$router.go(-1)
          console.log(res, '修改成功')
        })
      }
    }
  }
</script>

<style>
  $bg: #fff;
  $light_gray: #fff;
  $cursor: #fff;
</style>
